﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace UtilZ.Dotnet.Ex.Communication.Net.Web
{
    /// <summary>
    /// http请求参数异常
    /// </summary>
    public class HttpArgumentException : Exception
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="message">异常消息</param>
        /// <param name="exception">内部异常</param>
        public HttpArgumentException(string message, Exception exception)
            : base(message, exception)
        {

        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="message">异常消息</param>
        public HttpArgumentException(string message)
            : base(message)
        {

        }

        /// <summary>
        /// 构造函数
        /// </summary>
        public HttpArgumentException()
            : base()
        {

        }


        /// <summary>
        /// 重写ToString
        /// </summary>
        /// <returns>String</returns>
        public override string ToString()
        {
            string message = this.Message;
            var ex = this.InnerException;
            if (ex != null)
            {
                if (string.IsNullOrWhiteSpace(message))
                {
                    message = ex.ToString();
                }
                else
                {
                    message = $"{message},{ex.ToString()}";
                }
            }

            return message;
        }
    }
}
